<template>
  <a-modal
    :visible="visible"
    title="微信登录"
    :width="400"
    :confirmLoading="loading"
    class="education-dailog-login noNav"
    :footer="null"
    @cancel="()=>{$emit('cancel')}"
  >
    <a-spin :spinning="loading">
      <div class="education-login-wrap">
        <iframe
          :src="src"
          frameborder="0"
          sandbox="allow-scripts allow-top-navigation allow-same-origin"
          style="width: 282px; height: 400px"
        ></iframe>
      </div>
    </a-spin>
  </a-modal>
</template>
<script>
import { userThirdGetLoginUrl } from '@/api/login'

export default {
  props: {
    visible: {
      type: Boolean,
      required: true,
    },
    loading: {
      type: Boolean,
      default: () => false,
    },
  },
  data() {
    return {
      type: 1,
      src:'',
    }
  },
  methods: {
    handleClose() {
      this.$emit('close', false)
    },
  },
  watch:{
    visible:function(n){
      if(n){
        const redirectUrl = window.location.origin + window.location.pathname
        userThirdGetLoginUrl({redirectUrl}).then(res=>{
          this.src = res.data.url
        })
      }
    }
  }
}
</script>
<style lang="less" scoped>

.register-title {
  line-height: 24px;
  font-size: 18px;
}
.education-login-wrap {
  display: flex;
  justify-content: center;
}
.handleText {
  cursor: pointer;
}
</style>

